﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework;

namespace Super_Pong.Classes
{
    /*
    Classe incompleta. Autor: João Vitor
    NAO MECHER SEM AUTORIZAÇÃO DO AUTOR.
    */

    public class Player
    {
        #region Attributes 
        private string name;
        private long score;
        private long money;
        private Bar bar;        
        private KeyboardState keyboard;
        private enum mouseButtons{LEFT, RIGHT, NONE};
        #endregion

        #region Methods
        
        #region GetsAndSets
        public string GetName()
        {
            return name;
        }

        public void SetName(string name)
        {
            this.name = name;
        }

        public long GetScore()
        {
            return score;
        }

        public void SetScore(long score)
        {
            this.score = score;
        }

        public long GetMoney()
        {
            return money;
        }

        public void SetMoney(long money)
        {
            this.money = money;
        }

        public Bar GetBar()
        {
            return bar;
        }

        public void SetBar(Bar bar)
        {
            this.bar = bar;
        }

        public KeyboardState GetKeyboardState()
        {
            return keyboard;
        }
        #endregion

        /*public bool Buy(Weapon weapon)
        {
            if (money - weapon.GetPrice() >= 0)
            {
                money = money - weapon.GetPrice();
                return true;
            }
            else
                return false;
        }  --- Weapon é um barpiece */ 
        
        public bool Buy(BarPiece barPiece)
        {
            if (money - barPiece.GetPrice() >= 0)
            {
                money = money - barPiece.GetPrice();
                return true;
            }
            else
                return false;
        }

        //Return the key that is pressed. 
        private Keys PressedKey(KeyboardState keyboard)
        {
            KeyboardState pressedKey = new KeyboardState();

            switch (pressedKey.GetPressedKeys()[0])
            {
                case Keys.Up:
                    return Keys.Up;
                case Keys.Down:
                    return Keys.Down;
                case Keys.W:
                    return Keys.W;
                case Keys.S:
                    return Keys.S;
                //Is it necessary a key to the special?
                default:
                    return Keys.F1; //If the pressed key is not used in the game, the method returns the F1 key
            }
        }

       

        //retorna um enum que indica que botão foi pressionado 
        private mouseButtons PressedButton()
        {
            if (Mouse.GetState().LeftButton == ButtonState.Pressed)
            {
                return mouseButtons.LEFT;
            }
            else if (Mouse.GetState().RightButton == ButtonState.Pressed)
            {
                return mouseButtons.RIGHT;
            }
            else
                return mouseButtons.NONE;
        }

        public void Update(GameTime elapsedTime)
        {
            if (PressedKey(keyboard) == Keys.Up)
                bar.MoveUp(bar.getSpeed());
            if (PressedKey(keyboard) == Keys.W)
                bar.MoveUp(bar.getSpeed());
            if (PressedKey(keyboard) == Keys.Down)
                bar.MoveDown(bar.getSpeed());
            if (PressedKey(keyboard) == Keys.S)
                bar.MoveDown(bar.getSpeed());    
        }

        
        #endregion
        
        
        
    }
}
